package com.ms.config.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.monitor.api.ApiInfo;
import com.monitor.api.ApiRes;
import com.ms.config.task.UpdateConfigTask;
import com.system.handle.model.ResponseCode;
import com.system.handle.model.ResponseFrame;

@RestController
public class ConfigController {

	private static final Logger LOGGER = LoggerFactory.getLogger(ConfigController.class);
	
	@RequestMapping(name = "更新配置文件", value = "/config/update")
	@ApiInfo(params = {
	}, response = {
			@ApiRes(name="响应码[0成功、-1失败]", code="code", clazz=String.class, value="0"),
			@ApiRes(name="响应消息", code="message", clazz=String.class, value="success"),
			@ApiRes(name="主体内容", code="body", clazz=Object.class, value=""),
	})
	public ResponseFrame update() {
		try {
			ResponseFrame frame = UpdateConfigTask.updateConfig();
			return frame;
		} catch (Exception e) {
			LOGGER.error("处理业务异常: " + e.getMessage(), e);
			return new ResponseFrame(ResponseCode.SERVER_ERROR);
		}
	}
}
